
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="personal.dao.BookDAO"%>
<%@page import="personal.obj.Book"%>
<%@page import="java.util.Map.Entry"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.HashMap"%>
<%@page import="personal.obj.Cart"%>
<!DOCTYPE html>
<c:set var="cart" value="${sessionScope.CART}"/>
<c:set var="subTotal" value="${sessionScope.SUBTOTAL}"/>
<c:set var="sumQuantity" value="${sessionScope.SUMQUANTITY}"/>



<td class="rightContainer">
    <div class="quickCartSection">
        <div class="block floatLeft">
            <div class="cont">
                <h3>In your order</h3>
                <div class="total top">
                    <div class="corner1"></div>
                    <ul>
                        <li class="items"><a href="C_viewCartPage.jsp">Items: <span>${sumQuantity}</span></a></li>
                        <li class="name">Subtotal: <span>£${subTotal}</span></li>
                    </ul>
                </div>

                <%
                    if (session != null) {
                        Cart cart = (Cart) session.getAttribute("CART");
                        if (cart != null) {
                            HashMap items = cart.getItems();
                            if (!items.isEmpty()) {
                                Iterator iter = items.entrySet().iterator();
                                while (iter.hasNext()) {
                                    Map.Entry item = (Entry) iter.next();
                                    Book book = new Book();
                                    BookDAO bDAO = new BookDAO();
                                    book = bDAO.getBookByBookID(item.getKey().toString());
                                    if (book != null) {
                %>
                <div class="row">
                    <div class="productImg">
                        <a href="ProcessServlet?btAction=ProductDetail&productID=<%=book.getBookID()%>">
                            <img alt="<%=book.getBookName()%>" title="<%=book.getBookName()%>" src="<%=book.getBookThumb()%>">
                        </a>
                    </div>
                    <div class="name">
                        <a href="ProcessServlet?btAction=ProductDetail&productID=<%=book.getBookID()%>"><%=book.getBookName()%></a>
                        <p class="qtyPrice">Qty: <span><%=item.getValue()%></span> <span class="price">Price <%=book.getBookPrice()%></span></p>
                    </div>
                </div>
                <%
                                    }
                                }
                            }
                        }
                    }
                %>

                <table>
                    <tbody>
                        <tr class="last quickCartDelivery">
                            <td class="first">Delivery FREE</td>
                            <td class="last">£0.00</td>
                        </tr>
                        <tr class="last totals">
                            <td>Total</td>
                            <td class="last">£${subTotal}</td>
                        </tr>
                    </tbody>
                </table>


                <a class="editOrder" href="C_viewCartPage.jsp">Edit Order</a>
            </div>
            <div class="corner4">
                <div class="corner3">
                    <div class="lineBtm"></div>
                </div>
            </div>
        </div>
        <div class="nofloat"></div>
    </div>
    <div class="textSection">
        <div class="block">
            <div class="corner1"><div class="corner2"><div class="lineTop"></div></div></div>
            <div class="cont">
                <h3>
                    USEFUL LINKS</h3>
                <hr>
                <ul>
                    <li>
                        <a href="/page/Delivery+%26+Returns">Delivery &amp; returns</a></li>
                    <li>
                        <a href="/page/Terms+of+use">Terms of Use</a></li>
                    <li>
                        <a href="/page/Privacy+Policy">Privacy Policy</a></li>
                    <li>
                        <a href="/page/FAQs">FAQs</a>
                    </li>
                </ul>
                <hr>
            </div>
            <div class="corner4"><div class="corner3"><div class="lineBtm"></div></div></div>
        </div>
        <div class="nofloat"></div>
    </div>
</td>